package com.tengroup.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;

@Data
@TableName("user")
public class UserInfoEntity {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.AUTO)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;
    private String userName;
    private String userPassword;
    private Integer userClass;
    private Integer roleId;
    private String userTruename;
    private LocalDateTime creatTime;
    private Integer creatBy=0;
    private String salt;
    @TableField("user_email")
    private String userEmail;

    public UserInfoEntity(String username, String hashedPassword, String salt) {

        this.userName = username;
        this.userPassword = hashedPassword;
        this.creatTime = LocalDateTime.now();
    }

    public UserInfoEntity() {

    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserInfoEntity userInfoEntity = (UserInfoEntity) o;
        return Objects.equals(userId, userInfoEntity.userId) &&
                Objects.equals(roleId, userInfoEntity.roleId) &&
                Objects.equals(userName, userInfoEntity.userName) &&
                Objects.equals(userPassword, userInfoEntity.userPassword) &&
                Objects.equals(userClass, userInfoEntity.userClass) &&
                Objects.equals(userTruename, userInfoEntity.userTruename)&&
                Objects.equals(userEmail, userInfoEntity.userEmail);
    }
    @Override
    public int hashCode() {
        return Objects.hash(userId, userName, userPassword, userClass, userTruename);
    }
}


